1. Field of the Invention
The present invention relates to a defect counting method and apparatus for counting defect areas such as alien substances, spots, stains, dirt marks, dark spots, pinholes, and fish eyes on tested objects, by counting images of the defect areas contained in image data of the object detected by a sensor device such as a line CCD camera.
2. Description of the Related Art
Conventionally, a so-called labelling method is applied to count defect areas such as alien substances, spots, stains, dirt marks, dark spots, pinholes, and fish eyes contained in image data. The labelling method is a method wherein a label (name) is assigned to "1" pixels constituting a continuous area and another different label is assigned to "1" pixels constituting another continuous area, in a binary image. The method comprises a procedure wherein the same label is propagated to a neighboring "1" pixel and a procedure wherein if a continuous area encounters another continuous area having a different label, then a label of one area is replaced with that of another area.
In the counting method utilizing the labelling method, the binary image is scanned until a pixel having a value "1" is found. When a pixel having the value "1" is found, the value of the pixel is changed from "1" to ".mu." which is a minimum value among unused values for labelling. Next, the scanning process is continued. If a pixel having the value "1" and neighboring the pixel to which the label ".mu." has been assigned is found, the value of the found pixel is changed from "1" to ".mu.", if a pixel having the value "1" and not neighboring any pixel to which any label has been assigned, the value of the found pixel is changed from "1" to ".mu.+1" for new labelling, and the processes are repeated.
When the scanning process is finished, the value of the newest label corresponds to the number of the defect areas, namely, the number of the defect areas such as the alien substances, spots, strains, dirt marks, dark spots, pinholes, and fish eyes on the tested object.
However, in a defect counting method and apparatus using the aforementioned labelling, a memory capable of storing a large number is required for each pixel, and additionally, as the maximum value of the count is determined by the size of the memory, for example, if the memory has the size of 8 bits/pixel, the count can only go up to 256.